package bist.believeinstep.administrator.view;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.themes.Reindeer;


@SuppressWarnings("serial")
public class HeaderView extends HorizontalLayout implements View{
	private Label lblName;
	private Button btnLogout;
	
	public HeaderView (){
		inititalize();
	}
	
	private void inititalize(){
		this.setSizeFull();
		initLblName();
		initBtnLogout();	
	}
	
	private void initLblName(){
		lblName = new Label("Welcome, blu.nguyen");
		lblName.setSizeUndefined();
		lblName.setStyleName(Reindeer.LABEL_H2);
		addComponent(lblName);
		setComponentAlignment(lblName, Alignment.MIDDLE_LEFT);
	}
	
	private void initBtnLogout(){
		btnLogout = new Button("Logout");
		btnLogout.setStyleName(Reindeer.BUTTON_DEFAULT);
		
		btnLogout.addClickListener(new ClickListener() {
			
			@Override
			public void buttonClick(ClickEvent event) {
				getUI().getNavigator().addView(LoginView.NAME, LoginView.class);	
			}
		});
		addComponent(btnLogout);
		setComponentAlignment(btnLogout, Alignment.MIDDLE_RIGHT);	
	}

	@Override
	public void enter(ViewChangeEvent event) {
		
		
	}
}
